package com.duke.framework.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by duke on 2021/7/21
 */
public class RabbitMQConnectionUtils {


    /**
     * 获取rabbitMQ连接静态方法
     *
     * @return com.rabbitmq.client.Connection
     */
    public static Connection getConnection() throws IOException, TimeoutException {
        // 连接工厂
        ConnectionFactory factory = new ConnectionFactory();

        // 设置ip、端口
        factory.setHost("106.52.121.89");
        factory.setPort(5672);
        // 设置账户信息 vhost
        factory.setVirtualHost("test");
        factory.setUsername("duke");
        factory.setPassword("duke");

        return factory.newConnection();
    }

}
